package controllers

import (
	"github.com/gogf/gf/os/gcron"
)

type TaskController struct {
	BaseController
}

func (this *TaskController) Get() {
	taskname := this.GetString("name")
	entry := gcron.Search(taskname)
	if entry != nil {
		entry.Stop()
		this.Ctx.WriteString(entry.Name + "stop")
	} else {
		this.Ctx.WriteString("task null")
	}
}

func (this *TaskController) Post() {
	taskname := this.GetString("name")
	entry := gcron.Search(taskname)
	if entry != nil {
		entry.Stop()
		this.Ctx.WriteString(entry.Name + " stop")
	} else {
		this.Ctx.WriteString("task is not exist")
	}
}
